package com.xindz.cn.mvptest.components.main.view;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.xindz.cn.mvptest.R;
import com.xindz.cn.mvptest.shared.core.glide.GlideApp;
import com.xindz.cn.mvptest.shared.core.glide.GlideRequests;
import com.xindz.cn.mvptest.shared.core.image.ImageLoader;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @name MvpTest
 * @class name：com.xindz.cn.mvptest.components.main.view
 * @describe describe
 * @anthor XINDZ
 * @time 2017/10/31 16:05
 * @change
 * @chang time
 * @class describe
 */
public class TestActivity extends AppCompatActivity {
    @BindView(R.id.iv_1)
    ImageView iv1;
    @BindView(R.id.iv_2)
    ImageView iv2;
    @BindView(R.id.bt_test)
    Button btTest;
    @BindView(R.id.bt_test2)
    Button btTest2;
    private ImageLoader imageLoader;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        ButterKnife.bind(this);
        imageLoader = ImageLoader.getInstance(GlideApp.with(this));
    }

    @OnClick({R.id.bt_test, R.id.bt_test2})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.bt_test:
                imageLoader.defaultLoad("http://ww3.sinaimg.cn/large/7a8aed7bgw1eswencfur6j20hq0qodhs.jpg").into(iv1);
                break;
            case R.id.bt_test2:
                GlideRequests with = GlideApp.with(this);
                with.load("http://ww3.sinaimg.cn/large/7a8aed7bgw1eswencfur6j20hq0qodhs.jpg").into(iv2);
                break;
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        imageLoader = null;
    }
}
